package servlets;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import util.StringConstants;

import database.DatabaseOperations;

public class ViewJobs extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private DatabaseOperations databaseOperations;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		databaseOperations = new DatabaseOperations();
		try {
			String jsonText = "";
			jsonText = databaseOperations.getAllJobs().toString();
			PrintWriter out = response.getWriter();			
			response.setContentType("application/json");
		    response.setCharacterEncoding("UTF-8");		    
		    response.getWriter().write(jsonText); 
		} finally {
			databaseOperations.closeConnection();
		}
	}
}
